package controller.user;


import Message.Result;
import Message.entity.Setmeal;
import Message.vo.DishItemVO;
import Message.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import service.SetmealService;

import java.util.List;

@Slf4j
@RequestMapping("/user/setmeal")
@Api(tags = "用户套餐接口")
@RestController("userSetmealController")
public class SetmealController {


    @Autowired
    private SetmealService setmealService;


    /**
     * 根据分类ld查询套餐
     * @param categoryId
     * @return
     */
    @ApiOperation("根据分类ld查询套餐")
    @GetMapping("/list")
    public Result list(Long categoryId) {

       //构造返回参数，调service 处理业务请求
        List<SetmealVO> setmealVO = setmealService.list(categoryId);
        log.info("setmealVO={}", setmealVO.toString());

        return Result.success(setmealVO);
    }


    @ApiOperation("根据套餐id查询包含的菜品")
    @GetMapping("/dish/{id}")
    public Result ListDishById(@PathVariable("id") Long setmealId) {
        List<DishItemVO> dishItem = setmealService.ListDishById(setmealId);

        return Result.success(dishItem);
    }
















}
